
import 'package:shared_preferences/shared_preferences.dart';

/**
 * 存储数据到本地
 */
enum StoreKeys {
  userName, // 用户名
}

class Store {
  final SharedPreferences _store;
  static Future<Store> getInstance() async {
    SharedPreferences preferences = await SharedPreferences.getInstance();
    return Store._internal(preferences);
  }

  Store._internal(this._store);

  Object? getString(StoreKeys key) {
    return _store.get(getKey(key));
  }

  Future<bool> setString(StoreKeys key, String value) async {
    return _store.setString(getKey(key), value);
  }

  Future<bool> remove(StoreKeys key) async {
    return _store.remove(getKey(key));
  }

  String getKey(StoreKeys key){
    return key.toString();
  }

}
